#include "..\Inc\includes.h"

union		byte_def												FirstControllerSetAddr;														//控制器设置1
union		byte_def												SecondControllerSetAddr;													//控制器设置2

union		byte_def												FirstControllerStateAddr;													//控制器状态1
union		byte_def												SecondControllerStateAddr;												//控制器状态2

union		union_Display_RAM								LCD_RAM_Buffer;																		//定义一个显示缓存区

/* typedef -------------------------------------------------------------------*/
/* bdata area ----------------------------------------------------------------*/
// bdata: in 0x20 - 0x2f
unsigned char bdata 										ucFlag20;																					//in 
sbit 					Timer_1mS_CycleFlag								= ucFlag20 ^ 0;														//1mS时间到标志
sbit 					PowerKeyShortPressFlag						= ucFlag20 ^ 1;     											//电源键标志
sbit 					UpKeyShortPressFlag								= ucFlag20 ^ 2;    												//上移键标志
sbit 					DownKeyShortPressFlag							= ucFlag20 ^ 3;     											//下移键标志
sbit 					PowerKeyLongPressFlag							= ucFlag20 ^ 4;														//电源键长按标志
sbit 					UpKeyLongPressFlag								= ucFlag20 ^ 5;														//上移键长按标志
sbit 					DownKeyLongPressFlag							= ucFlag20 ^ 6;														//下移键长按标志
sbit 					KeyReleaseFlag										= ucFlag20 ^ 7;     											//按键释放标志

unsigned char bdata 										ucFlag21;																					//in 
sbit 					PowerKeyLongPressBackupFlag 			= ucFlag21 ^ 0;														//电源键长按标志备份
sbit 					UpAndDownKeyLongPressFlag					= ucFlag21 ^ 1;     											//脚踏启动标志置位
sbit 					UpAndDownKeyLongPressBackupFlag		= ucFlag21 ^ 2;    												//置位表示助力计算数据有变化
sbit 					HandleBarSampleFinishFlag					= ucFlag21 ^ 3;     											//置位表示转把有新的采样结果
sbit 					UartReceivedFlag									= ucFlag21 ^ 4;														//置位表示正在接收完成
sbit 					RefreshDisplayFlag								= ucFlag21 ^ 5;														//显示刷新标志，当显示数据有变动就刷新显示
sbit 					KMH_OR_MPH_Flag										= ucFlag21 ^ 6;														//千米时或者迈显示标志，置位显示迈速
sbit 					FunctionSetSaveFlag								= ucFlag21 ^ 7;     											//功能设置保存标志

unsigned char bdata 										ucFlag22;																					//in 
sbit 					FunctionSetFlag 									= ucFlag22 ^ 0;														//功能参数设置标志，置位设置状态
sbit 					FunctionSetFlashFlag							= ucFlag22 ^ 1;     											//在设置状态，功能区显示的数码管要闪烁
sbit 					UpKeyLongPressBackupFlag					= ucFlag22 ^ 2;    												//上移键长按标志备份
sbit 					DownKeyLongPressBackupFlag				= ucFlag22 ^ 3;     											//下移键长按标志备份
sbit 					SleepTimeFlag											= ucFlag22 ^ 4;														//休眠标志，置位开启休眠功能
sbit 					HandleBarErrorFlag								= ucFlag22 ^ 5;														//转把故障
//sbit 					KMH_OR_MPH_Flag										= ucFlag22 ^ 6;														//
//sbit 					FunctionSetSaveFlag								= ucFlag22 ^ 7;     											//



unsigned char							U8_KeyValue = 0;																								//键值
unsigned char							U8_KeyValueBakcup = 0;																					//键值备份
unsigned char							U8_UartReceiveCount = 0;																				//接收字节数计数器
unsigned char							U8_UartReceiveTimeOverCount = 0;																//接收超时计数器
unsigned char							U8_ConversionChannelIndex = 0;																	//ADC转换通道索引
unsigned char							U8_DIS_ODO_VOL_Index = 0;																				//单次里程=0，总里程=1，电压=2
unsigned char							U8_FunctionMenuIndex = 0x00;																		//功能菜单索引,最小菜单索引为1，最大为16,
unsigned char							U8_SpeedDisplay = 0;																						//车速
unsigned char							U8_VoltageOffset = 0;																						//电池电压偏移量，用于调整电压误差
unsigned char							U8_BatteryCellVoltage;																					//电池图标的每格电压值
unsigned char							U8_BatteryCellNumber = 0;																				//电池图标电量格数
unsigned char							U8_Gear_State = 0x01;																						//档位，默认为1档
unsigned char							U8_BlacklightClass = BLACKLIGHT_CLASS_FIRST;										//背光等级
unsigned char							U8_Blacklight_PWM_Value = BLACKLIGHT_CLASS_LOW;									//背光亮度
unsigned char							U8_RatedVoltageValue = RATED_VOLTAGE_36V;												//额定电压默认为36v
unsigned char							U8_SleepTimeValue = 0x0A;																				//休眠时间值
unsigned char							U8_SleepTimeCount = 0x00;																				//休眠计数器
unsigned char							U8_SpeedMeasureMagnetNumber = 0;																//测速磁钢数
unsigned char							U8_LimitSpeedValue = 0;																					//限速值
unsigned char							U8_DriveTypeValue = 0;																					//驱动方式
unsigned char							U8_AssistSensitivityValue = 0;																	//助力灵敏度
unsigned char							U8_AssistStartClassValue = 0;																		//助力启动强度度
unsigned char							U8_AssistMagentNumberValue = 0;																	//助力磁钢数
unsigned char							U8_AssistMagnetTypeSelect = 0;																	//助力磁盘类型选择
unsigned char							U8_WorkCurrentValue = 0;																				//工作电流值
unsigned char							U8_OdographSaveAddressOffset = 0;																//里程数保存地址偏移量

unsigned char							U8_UartSendData[20]={0x01,0x14,0x01,};													//发送的这三个字节是固定值，第0个字节为地址，第一个为帧长0x14=20，第二个为命令号，第3~18为数据，第19为校验和
unsigned char							U8_UartReceiveDataBuffer[14]={0x00},														//接收的数据缓存
													U8_UartReceiveData[14]={0x00};																	//接收的数据
unsigned int							U16_HandleBarBuffer[5]={0x00};																	//使用5个字节做转把电压缓存，											
//LCD 7段数字编码,编码格式-GFEDCBA
const unsigned char 			LCD_Code[]=
{
//  0		1		 2		3		 4		5		 6    7    8    9    A    B    C    D    E    F		blank
	0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F,0x77,0x7C,0x39,0x5E,0x79,0x71,0x00		//数码字0~F和不显示的编码
};													
unsigned char							U8_DisplayUnit = 0,
													U8_DisplayTen = 0,
													U8_DispalyHundred = 0,
													U8_DisplayThousand = 0,
													U8_DisplayTenThousand = 0;																			//数码字个十百千万位显示值
													
unsigned int							U16_HandelbarVoltage = 0,																				//转把电压
													U16_HandleTo_PWM_Duty = 0,																			//转把电压转换成PWM百分比，
													U16_ACC_Voltage = 0,																						//电门锁电压
													U16_PowerVoltage = 0,																						//电源电压
													U16_DistanceNumber = 0,																					//单次里程数
													U16_OdographNumber = 0,																					//里程数
													U16_ADC_ResultBuffer = 0;																				//ADC采样结果缓存

unsigned int							U16_ParameterValueStep = 0x01;																	//参数调节的步进，每按一次增量或减量值加1或减1
unsigned int							U16_ParameterValueStepBackup = 0x01;														//

unsigned int							U16_ParameterValueShowIndex = 0;																//在功能区数码管上显示的参数设置值	
unsigned int							U16_LowVoltageValue = 0;																				//欠压值，定点显示所以比实际值大10倍	
unsigned int							U16_WheelDiameterValue = 0;																			//轮径值，定点显示所有比实际值大10倍	
unsigned int							U16_SetStateSilencePeriod = 0;																	//在设置状态不操作时间10秒自动退出设置状态	,5毫秒调用，2000*5=10000=10秒									
/**********************SINOWEALTH_SH79F083A**********END OF FILE*************************/
